<?php

use app\common\services\StaticServices;

?>

<?= Yii::$app->view->renderFile('@app/modules/admin/views/common/tab_commission.php', ['tab' => 'index']) ?>
<div class="panel-content">
    <table class="ui selectable celled table">
        <input type="hidden" name="_csrf" id='csrf' value="<?= Yii::$app->request->csrfToken ?>">
        <thead>
        <tr>
            <th>客户姓名</th>
            <th>推荐人姓名</th>
            <th>佣金</th>
            <th>发放状态</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>

        <?php if ($list): ?>
            <?php foreach ($list as $item): ?>
                <tr>
                    <td><?= $item['member_name'] ?></td>
                    <td><?= $item['recommend_name'] ?></td>
                    <td><?= $item['recommend_commission'] ?></td>
                    <td>
                        <button class="tiny ui recommend_status button" data-status="<?= $item['commission_status'] ?>"
                                data-id="<?= $item['id'] ?>" data-recommend="<?= $item['recommend_id'] ?>">
                            <?= (StaticServices:: getCommissionStatus())[$item['commission_status']] ?>
                        </button>
                    </td>
                    <td><?= date('Y-m-d', $item['create_time']) ?></td>
                    <td>
                        <a href="javascript:void (0)"><i class="trash alternate icon _del"
                                                         data-status="<?= $item['commission_status'] ?>"
                                                         data-id="<?= $item['id'] ?>"></i></a>
                    </td>
                </tr>
            <?php endforeach; ?>
        <?php else: ?>
            <tr>
                <td colspan="5">暂无数据</td>
            </tr>
        <?php endif; ?>
        </tbody>

    </table>
</div>
<?= Yii::$app->view->renderFile('@app/modules/admin/views/common/page.php', ['total_page' => $total_page, 'p' => $p, 'url' => '/admin/recommend/commission']) ?>
<script type="text/javascript">
    require(['modules/recommend/commission'], function (commission) {
        commission.commission_del()
        commission.commission_editor()
    })
</script>